package com.nc.delivery_project.shared.locator;


import com.google.web.bindery.requestfactory.shared.Locator;
import com.nc.delivery_project.server.domain.User;
import com.nc.delivery_project.server.service.UserService;
import com.nc.delivery_project.shared.servicelocator.UserServiceLocator;

/**
 * Created by miroshnik on 02.12.14.
 */
public class UserLocator extends Locator<User, Integer> {

    @Override
    public User create(Class<? extends User> clazz) {
        return new User();
    }

    @Override
    public User find(Class<? extends User> clazz, Integer id) {
            return ((UserService) new UserServiceLocator().getInstance(null)).read(id);
    }

    @Override
    public Class<User> getDomainType() {
        return User.class;
    }

    @Override
    public Integer getId(User domainObject) {
        return domainObject.getId();
    }

    @Override
    public Class<Integer> getIdType() {
        return Integer.class;
    }

    @Override
    public Object getVersion(User domainObject) {
        //todo
        return domainObject.getId();
    }
}
